/**
 * Notes: 基础模块业务逻辑
 * Ver : CCMiniCloud Framework 2.0.1 ALL RIGHTS RESERVED BY cclinux0730 (wechat)
 * Date: 2025-11-14 07:48:00
 */

const pageHelper = require('@/utils/helper/page_helper.js');
class BaseBiz {
    static getCateName(cateId, cateList) {
        for (let k = 0; k < cateList.length; k++) {
            if (cateList[k].id == cateId) {
                return cateList[k].title;
            }
        }
        return '';
    }
    static getCateList(cateList) {
        let arr = [];
        for (let k = 0; k < cateList.length; k++) {
            arr.push({
                label: cateList[k].title,
                type: 'cateId',
                val: cateList[k].id,
                //for options form
                value: cateList[k].id //for list menu
            });
        }
        return arr;
    }
    static setCateTitle(cateList, cateId = null) {
        let curPage = pageHelper.getPrevPage(1);
        if (!curPage) {
            return;
        }
        if (!cateId) {
            if (curPage.options && curPage.options.id) {
                cateId = curPage.options.id;
            }
        }
        for (let k = 0; k < cateList.length; k++) {
            if (cateList[k].id == cateId) {
                uni.setNavigationBarTitle({
                    title: cateList[k].title
                });
                curPage.setData({
                    listMode: cateList[k].style || ''
                });
                return;
            }
        }
    }
	
	static setCateTitleNew(cateList, cateId = null) {
        // console.log('cateList', cateList, cateId);
	    for (let k = 0; k < cateList.length; k++) {
            console.log('cateList[k].id', cateList[k].id, cateId);
	        if (cateList[k].id == cateId) {
                console.log('cateList[k]', cateList[k]);
	            uni.setNavigationBarTitle({
	                title: cateList[k].name
	            });
	            curPage.setData({
	                listMode: cateList[k].style || ''
	            });
	            return;
	        }
	    }
	}
}
module.exports = BaseBiz;
